<?php
/**
 * @var $this yii\web\View
 */
use backend\assets\BackendAsset;
use backend\widgets\Menu;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\Breadcrumbs;

$bundle = BackendAsset::register($this);
?>
<?php $this->beginContent('@backend/views/layouts/base.php'); ?>
<div class="wrapper">
	<!-- header logo: style can be found in header.less -->
	<header class="main-header">
		<a href="<?= Yii::getAlias('@frontendUrl') ?>" class="logo">
            <!-- Add the class icon to your logo image or logo icon to add the margining -->
            <span class="logo-mini"><?= Yii::$app->params['appShortName']?></span>
            <span class="logo-lg"><b><?= Yii::$app->name?></b></span>
        </a>
		<!-- Header Navbar: style can be found in header.less -->
		<nav class="navbar navbar-static-top" role="navigation">
			<!-- Sidebar toggle button-->
			<a href="#" class="sidebar-toggle" data-toggle="offcanvas"
				role="button"> <span class="sr-only"><?= Yii::t('backend', 'Toggle navigation') ?></span>
				<span class="icon-bar"></span> <span class="icon-bar"></span> <span
				class="icon-bar"></span>
			</a>
			<div>
    		    <?= getSystemService()->getTopAdminMenusHtml()?>
			</div>
			<div class="navbar-custom-menu">
				<ul class="nav navbar-nav">
					<!-- Notifications: style can be found in dropdown.less -->
					<li id="log-dropdown" class="dropdown notifications-menu"><a
						href="#" class="dropdown-toggle" data-toggle="dropdown"> <i
							class="fa fa-warning"></i> <span class="label label-danger">
                                <?= \common\modules\system\models\SystemLog::find()->count()?>
                            </span></a>
						<ul class="dropdown-menu">
							<li class="header"><?= Yii::t('backend', 'You have {num} log items', ['num'=>\common\modules\system\models\SystemLog::find()->count()]) ?></li>
							<li>
								<!-- inner menu: contains the actual data -->
								<ul class="menu">
                                        <?php foreach(\common\modules\system\models\SystemLog::find()->orderBy(['log_time'=>SORT_DESC])->limit(5)->all() as $logEntry): ?>
                                            <li><a
										href="<?= Yii::$app->urlManager->createUrl(['/log/view', 'id'=>$logEntry->id]) ?>">
											<i
											class="fa fa-warning <?= $logEntry->level == \yii\log\Logger::LEVEL_ERROR ? 'text-red' : 'text-yellow' ?>"></i>
                                                    <?= $logEntry->category?>
                                                </a></li>
                                        <?php endforeach; ?>
                                    </ul>
							</li>
							<li class="footer">
                                    <?= Html::a(Yii::t('backend', 'View all'), ['/system/log/index'])?>
                                </li>
						</ul></li>
					<!-- User Account: style can be found in dropdown.less -->
					<li class="dropdown user user-menu"><a href="#"
						class="dropdown-toggle" data-toggle="dropdown"> <img
							src="<?= Yii::$app->user->identity->userProfile->getAvatar($this->assetManager->getAssetUrl($bundle, 'img/anonymous.jpg')) ?>"
							class="user-image"> <span><?= Yii::$app->user->identity->username ?> <i
								class="caret"></i></span></a>
						<ul class="dropdown-menu">
							<!-- User image -->
							<li class="user-header light-blue"><img
								src="<?= Yii::$app->user->identity->userProfile->getAvatar($this->assetManager->getAssetUrl($bundle, 'img/anonymous.jpg')) ?>"
								class="img-circle" alt="User Image" />
								<p>
                            <?= Yii::$app->user->identity->username?>
                            <small>
                                <?= Yii::t('backend', 'Member since {0, date, short}', Yii::$app->user->identity->created_at)?>
                            </small></li>
							<!-- Menu Footer-->
							<li class="user-footer">
								<div class="pull-left">
                                    <?= Html::a(Yii::t('backend', 'Profile'), ['/user/sign-in/profile'], ['class'=>'btn btn-default btn-flat'])?>
                                </div>
								<div class="pull-left">
                                    <?= Html::a(Yii::t('backend', 'Account'), ['/user/sign-in/account'], ['class'=>'btn btn-default btn-flat'])?>
                                </div>
								<div class="pull-right">
                                    <?= Html::a(Yii::t('backend', 'Logout'), ['/user/sign-in/logout'], ['class'=>'btn btn-default btn-flat', 'data-method' => 'post'])?>
                                </div>
							</li>
						</ul>
					</li>
					<!-- Control Sidebar Toggle Button -->
					<li><a href="#" data-toggle="control-sidebar"><i
								class="fa fa-gears"></i></a></li>
				</ul>
			</div>
		</nav>
	</header>
	<!-- Left side column. contains the logo and sidebar -->
	<aside class="main-sidebar">
		<!-- sidebar: style can be found in sidebar.less -->
		<section class="sidebar">
			<!-- Sidebar user panel -->
			<!--  
			<div class="user-panel">
				<div class="pull-left image">
					<img
						src="<?= Yii::$app->user->identity->userProfile->getAvatar($this->assetManager->getAssetUrl($bundle, 'img/anonymous.jpg')) ?>"
						class="img-circle" />
				</div>
				<div class="pull-left info">
					<p><?= Yii::t('backend', 'Hello, {username}', ['username'=>Yii::$app->user->identity->getPublicIdentity()]) ?></p>
					<a href="<?= Url::to(['/sign-in/profile']) ?>"> <i
						class="fa fa-circle text-success"></i>
                            <?= Yii::$app->formatter->asDatetime(time())?>
                        </a>
				</div>
			</div>
            -->
			<!-- sidebar menu: : style can be found in sidebar.less -->
			    
            <?= Menu::widget(
                [
                    'options' => [
                        'class' => 'sidebar-menu'
                    ],
                    'linkTemplate' => '<a href="{url}">{icon}<span>{label}</span>{right-icon}{badge}</a>',
                    'submenuTemplate' => "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n",
                    'activateParents' => true,
                    'items' => getSystemService()->getSidebarAdminMenuItems()
                ])?>
            </section>
		<!-- /.sidebar -->
	</aside>

	<!-- Right side column. Contains the navbar and content of the page -->
	<div class="content-wrapper">
		<!-- Content Header (Page header) -->
		<section class="content-header">
			<h1>
                <?= $this->title?>
                <?php if (isset($this->params['subtitle'])): ?>
                    <small><?= $this->params['subtitle'] ?></small>
                <?php endif; ?>
            </h1>

            <?= Breadcrumbs::widget([
                'tag' => 'ol',
                'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []
            ])?>
        </section>

		<!-- Main content -->
		<section class="content">
            <?php if (Yii::$app->session->hasFlash('alert')):?>
                <?= \yii\bootstrap\Alert::widget([
                    'body' => ArrayHelper::getValue(Yii::$app->session->getFlash('alert'), 'body'),
                    'options' => ArrayHelper::getValue(Yii::$app->session->getFlash('alert'), 'options')
                ])?>
            <?php endif; ?>
            <?= $content?>
        </section>
		<!-- /.content -->
	</div>
	<!-- /.content-wrapper -->

	<footer class="main-footer">
		<div class="pull-right hidden-xs">
			<b>Version</b> 1.0.0
		</div>
		<strong>Copyright &copy; 2015-2016 <a
			href="#">yiicenter</a>.
		</strong> All rights reserved.
	</footer>

	<!-- Control Sidebar -->
	<aside class="control-sidebar control-sidebar-dark">
		<!-- Create the tabs -->
		<ul class="nav nav-tabs nav-justified control-sidebar-tabs">
			<li class="active"><a href="#control-sidebar-options-tab" data-toggle="tab"><i
					class="fa fa-wrench"></i></a></li>
		</ul>
		<!-- Tab panes -->
		<div class="tab-content">
			<div class="tab-pane active" id="control-sidebar-options-tab">
				<h3 class="control-sidebar-heading">布局选项</h3>
                <div class="form-group">
                    <label class="control-sidebar-subheading">
                        <input class="pull-right" type="checkbox" data-layout="fixed" <?= Yii::$app->keyStorage->get('backend.layout-fixed')? 'checked': '' ?>>
                                                                        固定后台布局
                    </label>
                    <p>激活固定后台布局</p>
                </div>
                <div class="form-group">
                    <label class="control-sidebar-subheading">
                        <input class="pull-right" type="checkbox" data-layout="layout-boxed" <?= Yii::$app->keyStorage->get('backend.layout-boxed')? 'checked': '' ?>>
                                                                        盒式后台布局
                    </label>
                    <p>激活盒式后台布局</p>
                </div>
                <div class="form-group">
                    <label class="control-sidebar-subheading">
                        <input class="pull-right" type="checkbox" data-layout="sidebar-collapse">
                                                                        切换左侧边栏状态
                    </label>
                    <p>切换左侧边栏状态(开启或折叠)</p>
                </div>
                <div class="form-group">
                    <label class="control-sidebar-subheading">
                        <input class="pull-right" type="checkbox" data-enable="expandOnHover">
                                                                         鼠标经过展开左侧边栏
                    </label>
                    <p>鼠标经过展开最小化的左侧边栏</p>
                </div>
                <div class="form-group">
                    <label class="control-sidebar-subheading">
                        <input class="pull-right" type="checkbox" data-controlsidebar="control-sidebar-open">
                                                                        切换右侧边栏滑动效果
                    </label>
                </div>
                <div class="form-group">
                    <label class="control-sidebar-subheading">
                        <input class="pull-right" type="checkbox" data-sidebarskin="toggle">
                                                                        切换右侧边栏背景主题
                    </label>
                    <p>切换右侧边栏背景主题（dark、light）</p>
                </div>
				<h3 class="control-sidebar-heading">皮肤</h3>
			</div>
			<!-- /.tab-pane -->
		</div>
	</aside>
	<!-- /.control-sidebar -->
	<!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
	<div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<?php $this->endContent(); ?>